package com.lcredu.furn.response;

import lombok.Data;
import org.springframework.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 黎长容
 * @date 2025-08-04 19:43
 */
@Data
public class Result {
    //状态码
    private int code;

    //说明
    private String msg;
    //返回给浏览器的数据
    private Map<String, Object> extend = new HashMap<>();

    //成功
    public static Result success() {
        Result result = new Result();
        result.setCode(HttpStatus.OK.value());
        result.setMsg("success");
        return result;
    }

    public static Result fail() {
        Result result = new Result();
        result.setCode(400);
        result.setMsg("fail");
        return result;
    }


    public Result add(String key, Object value) {
        this.getExtend().put(key, value);
        return this;
    }

}
